package interfaces1;

class Dog1 implements Comparable{
	private int x;
	private double y;
	public Dog1( int x_in, double y_in){
		x = x_in; y = y_in;
	}
	public String toString(){
		return "( " + x + ", " + y + " )";
	}
	public int compareTo(Object o) {
		if (x > ((Dog1)o).x)
		  return 1;
		if (x < ((Dog1)o).x)
			return -1;
		return 0;
	}
}
public class Comparing1 {

	public static void main(String[] args) {
		Dog1 a = new Dog1( 4, 5.0 );
		Dog1 b = new Dog1( 7, 3.2 );
		
		System.out.println(" a is " + a);
		System.out.println(" b is " + b);
		
		System.out.println(" comparing a and b: " + a.compareTo(b));
		System.out.println(" comparing b and a: " + b.compareTo(a));
		System.out.println(" comparing a and a: " + a.compareTo(a));
		System.out.println(" comparing b and b: " + b.compareTo(b));
	}
}
